#include "graphicsutils.h"

void GraphicsUtils::showFloatingText(QGraphicsScene* scene, const QString& text, const QPointF& pos, int durationMs)
{
    auto* textItem = new QGraphicsTextItem(text);
    textItem->setDefaultTextColor(Qt::red);
    textItem->setFont(QFont("Arial", 20, QFont::Bold));
    textItem->setPos(pos);
    scene->addItem(textItem);

    QTimer::singleShot(durationMs, [scene, textItem]()
    {
        scene->removeItem(textItem);
        delete textItem;
    });
}
